import {Component} from '@angular/core';
import {
    AlertController, IonicPage, LoadingController, NavController, NavParams, Platform,
    ToastController
} from 'ionic-angular';
import {SystemService} from "../../service/SystemService";
import {Log} from "../../../framework/utils/Log";
import {NotifyItemPage} from "../../home/notify-item/notify-item";
import {BasePage} from "../../BasePage";
import {DomSanitizer} from "@angular/platform-browser";
import {UserManager} from "../../../framework/manager/UserManager";

/**
 * Generated class for the GuideItemPage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@IonicPage()
@Component({
    selector: 'page-guide-item',
    templateUrl: 'guide-item.html',
})
export class GuideItemPage extends BasePage {
    private static TAG: string = 'GuideItemPage';
    public context: string='';
    id: string;
    constructor(public navCtrl: NavController,
                public navParams: NavParams,
                public sys: SystemService,
                public sanitizer:DomSanitizer,
                public platform: Platform,
                public loadingCtrl: LoadingController,
                public toastCtrl: ToastController,
                public alertCtrl: AlertController) {
        super(platform, loadingCtrl, toastCtrl, alertCtrl);
        this.id = this.navParams.data.id;

    }

    ionViewDidLoad() {
        Log.w(GuideItemPage.TAG, 'ionViewDidLoad GuideItemPage');
        this.getGuideItem();
    }

    getGuideItem() {
        this.showLoading(true,'请稍后');

        let data: any = {
            BianHao: this.id,
            DanWeiBH:UserManager.getInstance().user.unitId
        };
        this.sys.getPayGuideDetails(data).subscribe((res: any) => {
            if (res.msgCode == '1') {
                Log.printObj(GuideItemPage.TAG, 'printObj==', res.detail);
                this.context = res.ZhiChuZN;
            } else {
                this.showError('数据加载失败')
            }
            this.showLoading(false,'请稍后');

        }, error => {
            this.showLoading(false,'请稍后');

            this.showError('数据加载失败')
        })
    }
    assembleHTML(strHTML:any){
        return this.sanitizer.bypassSecurityTrustHtml(strHTML);
    }

}
